package com.example.john.foodstore;


import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;


public class OrderAdapter extends BaseAdapter {
    private List<Order> orders;
    private LayoutInflater inflater;

    public OrderAdapter(List<Order> foods, LayoutInflater inflater) {
        this.orders = foods;
        this.inflater = inflater;
    }

    @Override
    public int getCount() {
        return orders.size();
    }

    @Override
    public Object getItem(int position) {
        return orders.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = inflater.inflate(R.layout.orders, null);
        final Order order = orders.get(position);
        TextView orderName = (TextView) convertView.findViewById(R.id.orderName);
        orderName.setText(order.getOrderName());
        TextView detail = (TextView) convertView.findViewById(R.id.detail);
        detail.setText(order.getDetail());
        /*ImageView snap = (ImageView) convertView.findViewById(R.id.snap);
        snap.setImageResource(order.getSnap());
        snap.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("Amy", order.getOrderName() + "....");
            }
        });*/

        return convertView;
         }
    }
